package extensionTools.smvCreator;

import java.util.ArrayList;


/**
* This class implements the SMV process.
* @author Oshrit & Lital.
*/
public class SmvProcess 
{
    private long id;
    private String name;
    private long fatherId; //if the process is not child fatherId = -1
    private ArrayList<Link> linkList;
    private ArrayList<Long> childrenIdList;
    private ArrayList<ArrayList<Link>> xorLists;
    private ArrayList<ArrayList<Link>> orLists;
    private int y;
    private int height;
    private int timeLine;
    private boolean fatherToLeafs;
    
    /**
     * Class constructor
     * @param id
     * @param name
     * @param fatherId
     * @param timeLine
     */
    public SmvProcess(long id, String name, long fatherId, int y, int height) 
    {
           this.id = id;
           this.name = SmvOp.setFirstCharToLowerCase(name.replaceAll(" ", "_").replaceAll("\n", "_"));
           this.fatherId = fatherId;
           childrenIdList = new ArrayList<Long>();
           linkList = new ArrayList<Link>();  
           xorLists = new ArrayList<ArrayList<Link>>();
           orLists = new ArrayList<ArrayList<Link>>();
           this.y = y;
           this.height = height;
           this.timeLine = -1;
           this.setFatherToLeafs(false);
    }

    public void setId(long id) {
            this.id = id;
    }

    public long getId() {
            return id;
    }

    public void setName(String name) {
            this.name = SmvOp.setFirstCharToLowerCase(name.replaceAll(" ", "_").replaceAll("\n", "_"));
    }

    public String getName() {
            return name;
    }

    public void setLinkList(ArrayList<Link> linkList) {
            this.linkList = linkList;
    }

    public ArrayList<Link> getLinkList() {
            return linkList;
    }

    public void setChildrenIdList(ArrayList<Long> childrenList) {
            this.childrenIdList = childrenList;
    }

    public ArrayList<Long> getChildrenIdList() {
            return childrenIdList;
    }

    public void setFatherId(long fatherId) {
            this.fatherId = fatherId;
    }

    public long getFatherId() {
            return fatherId;
    }

    public void setY(int y) {
            this.y = y;
    }

    public int getY() {
            return y;
    }

    public void setHeight(int height) {
            this.height = height;
    }

    public int getHeight() {
            return height;
    }
    

    public void setTimeLine(int timeLine) {
            this.timeLine = timeLine;
    }

    public int getTimeLine() {
            return timeLine;
    }

    public ArrayList<ArrayList<Link>> getXorLists() {
                return xorLists;
        }

        public ArrayList<ArrayList<Link>> getOrLists() {
                return orLists;
        }
            

    public void setFatherToLeafs(boolean isFatherToLeafs) {
            this.fatherToLeafs = isFatherToLeafs;
    }

    public boolean getFatherToLeafs() {
            return fatherToLeafs;
    }
        
    public boolean checkIfFatherToLeafs(ArrayList<SmvProcess> childrenList)
    {               
            for(int i = 0; i<childrenList.size();i++)
            {
                    if(childrenList.get(i).childrenIdList.size() == 0)
                    {
                            return true;
                    }
            }
            return false;
    }

        

}
